package com.tencent.qplus.paddata.stat;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class ParseLogByMonthJob extends Job {

	@Override
	public void stat(String[] args) {
		if(args!=null && args.length==1){
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
			try {
				Date argDate = sdf.parse(args[0]);
				Calendar cl = Calendar.getInstance();
				cl.setTime(argDate);
				cl.add(Calendar.MONTH, 1);
				Date endDate = cl.getTime();
				while(argDate.before(endDate)){
					new ParseLogFileJob().stat(new String[]{dateUtils.format(argDate)});
					argDate = dateUtils.getDateByDaysFromDate(argDate, 1);
				}
			} catch (ParseException e) {
				throw new IllegalArgumentException(e);
			}
		}else{
			throw new IllegalArgumentException("args error");
		}
	}

	@Override
	public void init() {
		// TODO Auto-generated method stub

	}

	@Override
	public void run() {
		// TODO Auto-generated method stub

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ParseLogByMonthJob job = new ParseLogByMonthJob();
		job.stat(args);

	}

}
